using Cinemachine;
using DG.Tweening;
using UnityEngine;

public class GameManager : Singleton<GameManager>
{

    [Header("伤害飘字")]
    public GameObject uiShowText;//伤害飘字预制体
    public DamageText damageText;//飘字特效预制体
    [Header("震动")]
    public CinemachineImpulseSource cinemachineImpulseSource;//Cinemachine的冲击源，用于摄像机震动效果\
    [Header("冲击波")]
    public RippleEffect rippleEffect;

    public override void Awake() {
        base.Awake();
    }

    //伤害飘字
    public void ShowText(string str, Transform tf, Color color)
    {
        GameObject text = ObjectPool.GetObject(uiShowText);
        text.GetComponent<UIShowText>().SetText(str, color, tf);
        // 生成位置 数值 是否暴击
        //  DamageText.Create(tf, Random.Range(1, 100), Random.Range(0, 100) < 30);
    }

    //相机抖动
    public void CameraShake(float force = 1f)
    {
        cinemachineImpulseSource.GenerateImpulse(force);// 生成摄像机震动效果
    }

    //触发冲击波
    public void PlayRippleEffect(Vector2 pos)
    {
        rippleEffect.gameObject.SetActive(true);
        rippleEffect.CallShockWave(pos);
    }
}
